package com.nuo.modules.common;

import com.nuo.common.utils.FileUtils;
import com.nuo.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@Api(tags = {"存储"})
@RestController
@RequestMapping("storage/local")
public class FileUploadController {

    @Autowired
    FileUtils fileUtils;

    // TODO 需部署至服务器才能生效
    @ApiOperation(value = "上传云服务器指定文件夹", consumes = "multipart/form-data")
    @PostMapping("/uploadByPathName")
    public R uploadByPathName(@RequestParam(value = "file") MultipartFile file, @RequestParam String pathName) {
        return fileUtils.uploadFileByPathName(file,pathName);
    }

}
